<template>
  <div>
    <breadl></breadl>
    <el-card>
      <el-table class="Hys_table" :data="tableData" border style="width: 100%">
        <el-table-column type="index" prop="#"></el-table-column>
        <el-table-column prop="order_number" label="订单编号" width="180"></el-table-column>
        <el-table-column prop="order_price" label="订单价格" width="180"></el-table-column>
        <el-table-column label="是否付款">
          <template slot-scope="scope">
            <div>
              <el-tag type="success" v-if="scope.row.pay_status == '1'">已支付</el-tag>
              <el-tag type="danger" v-else>未支付</el-tag>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货"></el-table-column>
        <el-table-column prop="update_time" label="下单时间"></el-table-column>
        <el-table-column prop="address" label="操作">
          <template v-slot="scope">
            <el-button type="primary" icon="el-icon-edit" circle size="mini"></el-button>
            <el-button type="primary" icon="el-icon-location" circle size="mini"></el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-dialog title="修改用户支付信息" :visible.sync="Visible" width="50%">
        <el-timeline>
          <el-timeline-item
            v-for="(activity, index) in Form"
            :key="index"
            :timestamp="activity.time"
          >{{ activity.context }}</el-timeline-item>
        </el-timeline>
        <span slot="footer" class="dialog-footer">
          <el-button @click="Visible = false">取 消</el-button>
          <el-button type="primary" @click="Visible = false">确 定</el-button>
        </span>
      </el-dialog>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryinFor.pagenum"
        :page-sizes="[1,3,5,10]"
        :page-size="queryinFor.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </el-card>
  </div>
</template>
<script>
import breadl from "../Bread.vue";

export default {
  components: {
    breadl
  },
  data() {
    return {
      tableData: [],
      Form: [],
      queryinFor: {
        pagenum: 1,
        pagesize: 10
      },
      total: 0,
      Visible: false
    };
  },
  created() {
    this.gettableData();
  },
  methods: {
    async gettableData() {
      const res = await this.$http.get("orders", { params: this.queryinFor });
      let { data, meta } = res.data;
      console.log(data, meta);
      if (meta.status == 200) {
        this.tableData = data.goods;
        this.total = data.total;
      }
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.queryinFor.pagesize = val;
      this.gettableData();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.queryinFor.pagenum = val;
      this.gettableData();
    }
  }
};
</script>
<style lang="scss">
.Hys_table {
  margin-top: 10px;
}
</style>

